// https://www.acwing.com/problem/content/4/

#include <iostream>
#include <vector>

using namespace std;

int solution(vector<int> volumes, vector<int> values, int maxVolume) {
    vector<int> dp(maxVolume + 1);
    dp[0] = 0;
    for (int i = 0; i < values.size(); i++) {
        for (int v = maxVolume; v >= volumes[i]; v--) {
            dp[v] = max(dp[v], dp[v-volumes[i]] + values[i]);
        }
    }
    return dp[maxVolume];
}

int main() {
    int n, maxVolume;
    cin>>n>>maxVolume;
    vector<int> volumes;
    vector<int> values;
    for (int i=0; i<n; i++) {
        int a, b, c;
        cin>>a>>b>>c;
        for (int j=1; j<=c; j++) {
            volumes.push_back(a * j);
            values.push_back(b);
        }
    }

    cout<<solution(volumes, values, maxVolume)<<endl;

    return 0;
}
